package com.atguigu.java;

/**
 * @author : leimingchao
 * @date Date : 2021年08月24日 23:57
 */
public class Person {

    String name;
    int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println("人：吃饭");
    }

    public void walk() {
        System.out.println("人：走路");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Person person = (Person) o;

        if (age != person.age) return false;
        return name != null ? name.equals(person.name) : person.name == null;
    }


    // @Override
    // public boolean equals(Object obj) {
    //
    //     if (obj == this) {
    //         return true;
    //     }
    //
    //     if (obj instanceof Person) {
    //         Person person = (Person) obj;
    //         return this.age == person.age && this.name.equals(person.name);
    //     }
    //     return false;
    // }
}
